package com.ebay.kr.services
{
	import com.ebay.kr.api.ticket.RequestApplicationTicketRequestT;
	import com.ebay.kr.api.ticket.RequestApplicationTicket_request;
	import com.ebay.kr.api.ticket.RequestTicketValidityPeriod_request;
	import com.ebay.kr.api.ticket.SecurityService;
	
	public class AuthTicket
	{
		public function AuthTicket()
		{
		}
		
		/**
		 * API용 인증티켓을 발급합니다.
		 * 인증티켓은 발급 후 1시간 동안 유효하며 티켓을 이용한 FxAPI호출 시 자동으로 유효시간이 갱신됩니다.
		 * 
		 * @param appId:String Application 아이디
		 * @param devId:String 회원 아이디
		 * @param appPassword:String Application 패스워드
		 * @param result:Function 티켓 발급 결과 처리용 function
		 * @param fault:Function 티켓 발급 실패 처리용 function
		 */
		public function requestApplicationTicket(appId:String, devId:String, appPassword:String, result:Function, fault:Function):void
		{
			var s:SecurityService = new SecurityService();
			var req:RequestApplicationTicket_request = new RequestApplicationTicket_request();
			var reqT:RequestApplicationTicketRequestT = new RequestApplicationTicketRequestT();
			
			reqT.AppID = appId;
			reqT.DevID = devId;
			reqT.AppPassword = appPassword;
			
			req.req = reqT;
			
			s.requestApplicationTicket_request_var = req;
			
			s.addrequestApplicationTicketEventListener(result);
			s.addSecurityServiceFaultEventListener(fault);
			s.requestApplicationTicket_send();
		}
		
		public function requestTicketValidityPeriod(encryptedTicket:String, result:Function, fault:Function):void
		{
			var s:SecurityService = new SecurityService();
			var req:RequestTicketValidityPeriod_request = new RequestTicketValidityPeriod_request();
			
			req.encryptedTicket = encryptedTicket;
			
			s.requestTicketValidityPeriod_request_var = req;
			
			s.addrequestTicketValidityPeriodEventListener(result);
			s.addSecurityServiceFaultEventListener(fault);
			s.requestTicketValidityPeriod_send();
		}

	}
}